package store

import (
	"fmt"

	"file_explorer/common/consts"
	"file_explorer/common/util"
	"file_explorer/model"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/theme"
)

type FileCreateTabContext struct {
	DefaultTabContext

	Path            string
	CreateFileInfos []*model.FileInfo
}

func (ctx *FileCreateTabContext) GetTabType() string {
	return consts.TabTypeFileCreate
}

func (ctx *FileCreateTabContext) GetTabLabel() string {
	dirs := util.PathSplit2Nodes(ctx.Path)
	return fmt.Sprintf("%s: %s", ctx.GetTabType(), dirs[len(dirs)-1])
}

func (ctx *FileCreateTabContext) GetTabIcon() fyne.Resource {
	return theme.FolderNewIcon()
}

func NewFileCreateTabContext(fileTabContext *FileTabContext) *FileCreateTabContext {
	ctx := &FileCreateTabContext{
		DefaultTabContext: newDefaultTabContext(fileTabContext.GetGlobalContext()),
		Path:              fileTabContext.GetPath(),
	}

	return ctx
}
